home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 22
/
Cream of the Crop 22.iso
/
program
/
eflibpt4.zip
/
DEMO
/
DATATYPE
/
TRANSFER.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1996-08-18
|
2KB
|
48 lines
{ Borland Pascal Extended Function Library - EFLIB (C) Johan Larsson, 1996
Demonstration; import and export to other data types and to data streams
EFLIB IS PROTECTED BY THE COPYRIGHT LAW AND MAY NOT BE COPIED, SOLD OR
MANIPULATED. FOR MORE INFORMATION, SEE PROGRAM MANUAL! THIS DEMONSTRAT-
ION PROGRAM MAY FREELY BE USED AND DISTRIBUTED. }
uses EFLIBDEF, EFLIBINI, EFLIBDAT, EFLIBIO;
var DataType1 : ArrayListObjectType; DataType2 : LinkedListObjectType;
Stream : FileStreamObjectType; SomeData : string; Index : word;
begin
DataType1.Initialize (9, SizeOf(String));
DataType2.Initialize (SizeOf(String));
{ Create two duplicate data types }
SomeData := '1'; DataType1.Add (SomeData); DataType2.Add (SomeData);
SomeData := '2'; DataType1.Add (SomeData); DataType2.Add (SomeData);
SomeData := '3'; DataType1.Add (SomeData); DataType2.Add (SomeData);
{ Export second data types element into the first, and then let the
first data type import the same elements one more time. }
DataType2.Export (@DataType1);
DataType1.Import (@DataType2);
WriteLn ('* First data type; lot''s of imported elements *');
for Index := 1 to DataType1.Elements do
Write ('[', Index:1, ']: ', String(DataType1.ElementPointer(Index)^):1, '':2);
{ Import and export elements to DataType1 file stream }
with Stream do begin
Initialize ('elements.$$$', 2000);
DataType1.StreamExport (@Stream);
Intercept;
end;
WriteLn; WriteLn ('* Second data type; the original elements *');
for Index := 1 to DataType2.Elements do
Write ('[', Index:1, ']: ', String(DataType2.ElementPointer(Index)^):1, '':2);
DataType1.Intercept; DataType2.Intercept;
DeleteFile ('elements.$$$');
if GlobalDataError then WriteLn ('Error(s) reported!');
end.